home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 August / ENTER.ISO / files / gimp-2.0.5-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-glow-button.scm < prev    next >
Encoding:
Text File  |  2004-09-26  |  4.9 KB  |  154 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed button
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on code from Frederico Mena Quintero (Quartic)
  8. ; federico@nuclecu.unam.mx
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ; GNU General Public License for more details.
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (text-width extents)
  24.   (car extents))
  25.  
  26. (define (text-height extents)
  27.   (cadr extents))
  28.  
  29. (define (text-ascent extents)
  30.   (caddr extents))
  31.  
  32. (define (text-descent extents)
  33.   (cadr (cddr extents)))
  34.  
  35. (define (blend-bumpmap img
  36.                drawable
  37.                x1
  38.                y1
  39.                x2
  40.                y2)
  41.   (gimp-edit-blend drawable FG-BG-RGB-MODE DARKEN-ONLY-MODE
  42.            GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  43.            FALSE 0 0 TRUE
  44.            x1 y1 x2 y2))
  45.  
  46. (define (script-fu-alien-glow-button text
  47.                      font
  48.                      size
  49.                      text-color
  50.                      glow-color
  51.                      bg-color
  52.                      padding
  53.                      glow-radius
  54.                      flatten)
  55.   (let* ((old-fg-color (car (gimp-palette-get-foreground)))
  56.      (old-bg-color (car (gimp-palette-get-background)))
  57.      (text-extents (gimp-text-get-extents-fontname text
  58.                                size
  59.                                PIXELS
  60.                                font))
  61.      (ascent (text-ascent text-extents))
  62.      (descent (text-descent text-extents))
  63.      
  64.      (img-width (+ (* 2  padding)
  65.                (text-width text-extents)))
  66.      (img-height (+ (* 2 padding)
  67.             (+ ascent descent)))
  68.      (layer-height img-height)
  69.      (layer-width img-width)
  70.      (img-width (+ img-width glow-radius))
  71.      (img-height (+ img-height glow-radius))
  72.      (img (car (gimp-image-new  img-width   img-height  RGB)))
  73.      (bg-layer (car (gimp-layer-new img
  74.                     img-width img-height RGBA-IMAGE
  75.                     "Background" 100 NORMAL-MODE)))
  76.      (glow-layer (car (gimp-layer-new img
  77.                       img-width img-height RGBA-IMAGE
  78.                       "Glow" 100 NORMAL-MODE)))
  79.      (button-layer (car (gimp-layer-new img
  80.                         layer-width layer-height RGBA-IMAGE
  81.                         "Button" 100 NORMAL-MODE))))
  82.  
  83.     (gimp-image-undo-disable img)
  84.  
  85.     ; Create bumpmap layer
  86.     
  87.     (gimp-image-add-layer img bg-layer -1)
  88.     (gimp-palette-set-foreground '(0 0 0))
  89.     (gimp-palette-set-background bg-color)
  90.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  91.     (gimp-image-add-layer img glow-layer -1)
  92.  
  93.     ; Create text layer
  94.  
  95.     (gimp-image-add-layer img button-layer -1)
  96.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  97.     (gimp-selection-none img)
  98.     (gimp-rect-select img 0 0 img-width img-height CHANNEL-OP-REPLACE FALSE 0)
  99.     (gimp-palette-set-foreground '(100 100 100))
  100.     (gimp-palette-set-background '(0 0 0))
  101.  
  102.     (gimp-edit-blend button-layer FG-BG-RGB-MODE NORMAL-MODE
  103.              GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  104.              FALSE 0 0 TRUE
  105.              0 0 img-height img-width)
  106.  
  107.     (gimp-edit-clear glow-layer)
  108.  
  109.     (gimp-rect-select img
  110.               (/ glow-radius 4)
  111.               (/ glow-radius 4)
  112.               (- img-width (/ glow-radius 2))
  113.               (- img-height (/ glow-radius 2))
  114.               CHANNEL-OP-REPLACE FALSE 0 )
  115.  
  116.     (gimp-palette-set-foreground glow-color)
  117.     (gimp-edit-fill glow-layer FOREGROUND-FILL)
  118.     (gimp-selection-none img)
  119.     (plug-in-gauss-rle 1 img glow-layer glow-radius TRUE TRUE)
  120.     (gimp-palette-set-foreground text-color)
  121.     (let ((textl (car (gimp-text-fontname
  122.                img -1 0 0 text 0 TRUE size PIXELS font))))
  123.       (gimp-layer-set-offsets textl
  124.                   (+  padding (/ glow-radius 2))
  125.                   (+ (+ padding descent) (/ glow-radius 2))))
  126.     ; Done
  127.     (gimp-selection-none img)
  128.     (gimp-palette-set-foreground old-fg-color)
  129.     (gimp-palette-set-background old-bg-color)
  130.     (gimp-image-undo-enable img)
  131.     (if (= flatten TRUE)
  132.     (gimp-image-flatten img))
  133.     (gimp-display-new img)))
  134.  
  135. (script-fu-register "script-fu-alien-glow-button"
  136.             _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Alien Glow/B_utton..."
  137.             "Button with an eerie glow"
  138.             "Adrian Likins"
  139.             "Adrian Likins"
  140.             "July 1997"
  141.             ""
  142.             SF-STRING     _"Text"               "Hello world!"
  143.             SF-FONT       _"Font"               "Futura_Poster"
  144.             SF-ADJUSTMENT _"Font Size (pixels)" '(22 2 100 1 1 0 1)
  145.             SF-COLOR      _"Text Color"         '(0 0 0)
  146.             SF-COLOR      _"Glow Color"         '(63 252 0)
  147.             SF-COLOR      _"Background Color"   '(0 0 0)
  148.             SF-ADJUSTMENT _"Padding"            '(6 1 100 1 10 0 1)
  149.             SF-ADJUSTMENT _"Glow Radius"        '(10 1 200 1 10 0 1)
  150.             SF-TOGGLE     _"Flatten Image"      TRUE)
  151.